from typing import Literal

from fastapi.responses import JSONResponse

from common.base.base_routers import get_custom_router
from services.killer.api import KillerApi
from common.utils import make_literal
from settings import settings

killer_api = KillerApi()
killer_router = get_custom_router(killer_api, prefix='/killer', tags=['killer'])


@killer_router.get('/get-all-services/', response_class=JSONResponse)
async def get_all_services():
    return await killer_api.get_all_services()


@killer_router.get('/switch_service/', response_class=JSONResponse)
async def switch_service(name: make_literal(settings.SERVICES_NAME_STATIC),
                         action: make_literal(['on', 'off', 'reboot'])):
    return await killer_api.switch_service(name, action)
